﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;

namespace Sigil.Impl
{
	internal class InstructionAndTransitions
	{
		public List<StackTransition> Transitions { get; private set; }

		public OpCode? Instruction { get; private set; }

		public Int32? InstructionIndex { get; private set; }

		public InstructionAndTransitions(OpCode? instr, Int32? ix, List<StackTransition> trans)
		{
			Instruction = instr;
			Transitions = trans;
			InstructionIndex = ix;
		}

		public override String ToString()
		{
			if (!Instruction.HasValue) return String.Join(", ", Transitions.Select(t => t.ToString()).ToArray());

			return "[" + Instruction + " @" + InstructionIndex + "] " + String.Join(", ", Transitions.Select(t => t.ToString()).ToArray());
		}
	}
}